docs: Update query examples to use eq() helper for boolean comparisons#1299
Merged
KyleAMathews merged 1 commit intomainfrom Feb 25, 2026
Merged
Conversation
…ean expressions The .where() clause requires expression objects (via eq(), gt(), etc.), not raw JavaScript boolean expressions. Bare property references like `todo.completed` or negated expressions like `!todo.completed` fail the isExpressionLike() validation at runtime, throwing InvalidWhereExpressionError. Fixed in docs/overview.md, docs/guides/schemas.md, docs/collections/trailbase-collection.md, docs/reference/classes/BaseQueryBuilder.md, and source JSDoc in packages/db/src/query/builder/index.ts. Fixes #1297 https://claude.ai/code/session_01VD8cnL4qhw4k5XKaK9qL8L
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Contributor
|
Size Change: +2 B (0%) Total Size: 92.6 kB
ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 3.7 kB ℹ️ View Unchanged
|
thruflo
approved these changes
Feb 25, 2026
kevin-dp
reviewed
Feb 26, 2026
| const { data: todos } = useLiveQuery((q) => | ||
| q.from({ todo: todosCollection }) | ||
| .where(({ todo }) => !todo.completed) | ||
| .where(({ todo }) => eq(todo.completed, false)) |
Contributor
There was a problem hiding this comment.
This is not very idiomatic. Should be not(todo.completed).
| const { data: todos } = useLiveQuery(q => | ||
| q.from({ todo: todoCollection }) | ||
| .where(({ todo }) => !todo.completed) | ||
| .where(({ todo }) => eq(todo.completed, false)) |
| // Bind data using live queries | ||
| const { data: todos } = useLiveQuery((q) => | ||
| q.from({ todo: todoCollection }).where(({ todo }) => todo.completed) | ||
| q.from({ todo: todoCollection }).where(({ todo }) => eq(todo.completed, false)) |
Contributor
There was a problem hiding this comment.
should be not(todo.completed)
| const { data: products } = useLiveQuery(q => | ||
| q.from({ product: productCollection }) | ||
| .where(({ product }) => product.in_stock) // Use computed field | ||
| .where(({ product }) => eq(product.in_stock, true)) // Use computed field |
Contributor
There was a problem hiding this comment.
Normally, there should be no reason to use eq here and just product.in_stock should work as it is a boolean, but i know we don't support that yet... It should be though. I'll open an issue for it.
Contributor
There was a problem hiding this comment.
I have an open PR #1304 that fixes this so let's write this in the idiomatic way in the docs and let's merge the docs when the PR is merged.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
fix #1297
Updated documentation examples and code comments to use the
eq()helper function for boolean field comparisons in.where()clauses instead of relying on implicit boolean coercion.Changes made:
eqfrom@tanstack/react-dband@tanstack/dbwhere needed!todo.completed,product.in_stock,u.active) with expliciteq()calls (e.g.,eq(todo.completed, false),eq(product.in_stock, true),eq(u.active, true))docs/guides/schemas.md(todo and product examples)docs/collections/trailbase-collection.md(todo example)docs/reference/classes/BaseQueryBuilder.md(API documentation)docs/overview.md(overview example)packages/db/src/query/builder/index.ts(JSDoc comments)This change promotes consistency and clarity in query syntax by using the explicit
eq()helper for all boolean comparisons, making the intent clearer and aligning with best practices for query building.✅ Checklist
🚀 Release Impact
https://claude.ai/code/session_01VD8cnL4qhw4k5XKaK9qL8L